﻿CREATE PROCEDURE [dbo].[usp_UserApplication_Del]
@ID INT, @TimeStmp TIMESTAMP
AS
BEGIN

DECLARE @ErrorCode AS INT
DECLARE @RowsAffected AS INT

DELETE FROM [UserApplication] WITH (ROWLOCK)
    WHERE ([ID] = @ID) AND ([TimeStmp] = @TimeStmp)
    OPTION (FAST 1)

SELECT @ErrorCode = @@ERROR, @RowsAffected = @@ROWCOUNT

IF @RowsAffected = 0
    RETURN 50001  -- concurrency violation

RETURN @ErrorCode

END

